package com.cn.scenario.controller;

import com.cn.scenario.util.mq.pojo.StrsqlResData;
import com.cn.scenario.util.mq.produder.ProduderService;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author Boolean  修改注释
 * @Date 2022/12/21 22:44
 * @Version 1.0
 */
@RestController
public class ScenarioController {
    //加入注释
    /*@Autowired
    private RedisTemplate<String, Object> template;*/

    @Autowired
    private ProduderService produderService;

    @RequestMapping("/")
    public Object i(HttpServletRequest request) {
        Map<String, Object> res = new HashMap<String, Object>();
        res.put("ip:", request.getScheme() + "://" + request.getServerName()
                + ":" + request.getServerPort() + request.getRequestURI());

        return res;
    }

        //测试2

    /*@RequestMapping("/testRedis")
    public String testRedis() {
        template.opsForValue().set("demo", "hello world! 你好，世界");
        String str = (String) template.opsForValue().get("demo");
        return str;
    }*/


    @RequestMapping("/produder")
    public int produder(HttpServletRequest request) {
        List<StrsqlResData> strsqlResDataList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            StrsqlResData strsqlResData = new StrsqlResData();
            strsqlResData.setId("c"+i);
            strsqlResData.setMsg("d"+i);
            strsqlResDataList.add(strsqlResData);
        }
        produderService.produder_to(strsqlResDataList);
        return 1;

    }

}
